package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;


public class EnviarMensagemDAO {
	
	private Connection connection;
	
	public EnviarMensagemDAO() throws SQLException{
		this.connection = ConnectionFactory.getConnection();
	}
	
	public void adiciona(String origem, String destino, boolean broadcast, String msg ) 
		throws SQLException {
		
		String sql = "insert into mensagens" +
		"(cpf_origem,cpf_destino,mensagem,broadcast)" +
		"values(?,?,?,?)";
		
		PreparedStatement stmt = connection.prepareStatement(sql);
		
		stmt.setString(1, origem);
		stmt.setString(2, destino);
		stmt.setString(3, msg);
		stmt.setBoolean(4, broadcast);		
		
		stmt.execute();
		stmt.close();	
	}
}
